package com.artist.controller;

import com.artist.entity.TbCate;
import com.artist.service.CateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "一级导航栏")
@Controller
public class CateController {
    @Autowired
    private CateService cateService;
    @ApiOperation(value = "一级导航列表")
    @GetMapping("/cate")
    @ResponseBody
    public List<TbCate> cateAll(){
        return cateService.allCate();
    }
    @ApiOperation(value = "查询导航栏")
    @GetMapping("/cate/{cateId}")
    @ResponseBody
    private TbCate selectCateByPrimaryKey(@PathVariable Long cateId){
        return cateService.selectByPrimaryKey(cateId);
    }
    @ApiOperation(value = "添加一级导航栏")
    @PostMapping("/cate")
    public String insertCate(@RequestBody TbCate tbCate){
        cateService.saveCate(tbCate);
        return "allcate";
    }
    @ApiOperation(value = "编辑一级导航栏")
    @PutMapping("/cate/{cateID}")
    public String updateCate(@RequestBody TbCate tbCate){
        cateService.updateCate(tbCate);
        return "allcate";
    }
    @ApiOperation(value = "删除一级导航")
    @DeleteMapping("/cate/{cateId}")
    public String deleteCate(@PathVariable Long cateId){
        cateService.deleteCate(cateId);
        return "allcate";
    }
}
